package com.techstar.ats.netty;

import io.netty.buffer.ByteBuf;
import com.techstar.ats.codec.Codec;

public enum APDUCodec implements Codec<APDU> {
	INSTANCE;

	public static final int LEN = 4;

	public APDU create() {
		return new APDU();
	}

	public void encode(ByteBuf buf, APDU value) {
		buf.writeByte(value.systemId);
		buf.writeShort(value.len);
		buf.writeBoolean(value.multi);
	}

	public void decode(ByteBuf buf, APDU value) {
		value.systemId = buf.readUnsignedByte();
		value.len = buf.readUnsignedShort();
		value.multi = buf.readBoolean();
	}
}
